package h0708;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class PeopleAllocate {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int m = sc.nextInt(); //m辆自行车
        //n个人，每个人的限重
        sc.nextLine();
        int[] requires = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        getResult(m,requires);
    }

    private static void getResult(int m, int[] requires) {
        Arrays.sort(requires);
        long min=requires[0];
        int length = requires.length;
        long max=requires[length -1]+requires[length-2];
        long ans=max;
        while (min<=max){
            long mid=min+(max-min)/2;

            if (check(mid,m,requires)){
                //将当前限重mid赋值给ans
                ans=mid;
                //继续寻找有没有更小的解
                max=mid-1;
            }else {
                min=mid+1;
            }
        }
        System.out.println(ans);
    }

    //m辆自行车，每辆限重limit的情况下，能否带走n个人
    private static boolean check(long limit,int m,int[] requires){
        int l=0;
        int r= requires.length-1;

        //需要几辆车
        int need=0;
        while (l<=r){
            //如果最轻和最重的人可以坐一辆车l++,r--;
            //否则，最重的人只能坐一辆车 r--
            if (requires[l]+requires[r]<=limit){
                l++;
                r--;
            }else {
                r--;
            }
            need++;
        }
        return need<=m;
    }

}
